package com.project.finance.exchange.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.project.finance.common.mapper.TbExchangeMapper;
import com.project.finance.common.po.TbExchange;
import com.project.finance.common.vo.ResultMsg;
import com.project.finance.exchange.service.ExchangeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ExchangeServiceImpl implements ExchangeService {

    @Resource
    private TbExchangeMapper exchangeMapper;

    @Override
    public void selectByCountry() {

    }


    //查询所有
    @Override
    public List<TbExchange> selectAll() {
        return exchangeMapper.selectAll();
    }





    //修改汇率
    @Override
    public int update(TbExchange tbExchange) {

        return exchangeMapper.updateByPrimaryKey(tbExchange);
    }

    @Override
    public ResultMsg listExchangeByPage(int pageSize, int pageNum) {
        ResultMsg resultMsg = new ResultMsg();

        PageHelper.startPage(pageNum,pageSize);

        List<TbExchange> tbExchanges = exchangeMapper.selectAll();

        //获取结果集的分页信息
        PageInfo pageInfo = new PageInfo(tbExchanges);
        //获取总记录数
        long total = pageInfo.getTotal();
        resultMsg.setTatol(total);
        resultMsg.setData(tbExchanges);
        return resultMsg;
    }


}
